blob: 023c3ff99377945d4ab60baf06b5c779c05f9211 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
import type { PageLoad } from './$types'
import { fetchApi } from '$lib/api'
import { error, redirect } from '@sveltejs/kit'
export const load = (async ({ params, fetch }) => {
const player: string = params.player!
const data = await fetchApi(`player/${player}?customization=true`, fetch).then(r => r.json())
if (!data.player) {
throw error(404, 'Unknown player')
}
if (data.player.username !== player) {
throw redirect(302, `/player/${data.player.username}`)
}
return data
}) satisfies PageLoad
|